import React, { useState } from 'react';
import { axconst } from '@/shared/axconst';
import { AxStandardCardButtonType, AxStandardCardFilterType } from '@/components/AxList/AxStandardLayout/data.d';
import { AxStandardWideList } from '@/components/AxList/AxStandardWideList';
import { axurl } from '@/shared/axurl';
import { AxColumnEnum } from '@/components/AxList';
import Material from './components/material';

const url = axurl.material.order.havestore;
const Index: React.FC<any> = props => {
    const [expandedRowKeys, setExpandedRowKeys] = useState(['1']);

    /** 配置列 */
    const columns: any[] = [
        {
            title: '订单编号',
            dataIndex: 'orderId',
            width: axconst.width.long,
        },
        {
            title: '订单标题',
            dataIndex: 'title',
            width: axconst.width.long,
        },
        {
            title: '商品名称',
            dataIndex: 'name',
            width: axconst.width.long,
        },
        {
            title: '数量',
            dataIndex: 'amount',
            width: axconst.width.fouronly,
        },
        {
            title: '订单总额',
            dataIndex: 'sumMoney',
            width: axconst.width.fouronly,
        },
        {
            title: '支付经费',
            dataIndex: 'itemName',
            width: axconst.width.long,
        },
        {
            title: '收货地址',
            dataIndex: 'address',
            width: axconst.width.long,
        },
        {
            title: '下单时间',
            dataIndex: 'created',
            width: axconst.width.time,
        },
        {
            title: '状态',
            dataIndex: 'orderStatus',
            width: axconst.width.fouronly,
            render: (val: any) => AxColumnEnum({ enumName: 'orderStatus', value: val }),
        },
        {
            title: '供应商',
            dataIndex: 'supplierName',
            width: axconst.width.long,
        },
    ];

    /** 配置操作按钮 */
    const button: AxStandardCardButtonType[] = [];

    const filter: AxStandardCardFilterType[] = []

    const handleExpandedRowsChange = (expandedRows: any) => {
        setExpandedRowKeys(expandedRows);
    };

    return (
        <>
            <AxStandardWideList
                url={url}
                size='default'
                bodyStyle={{ padding: 0 }}
                columns={columns}
                button={button}
                filter={filter}
                data={{...axconst.data}}
                checkboxModel={false}
                showTopSlider={false}
                // showSimpleSearch={false}
                // AdvancedSearch={Search}
                expandedRowKeys={expandedRowKeys}
                onExpandedRowsChange={handleExpandedRowsChange}
                expandedRowRender={(record: any) => (
                    <Material orderId={record.orderId} />
                )}
            />
        </>
    );
};

export default Index;
